package com.iodemo;

import org.apache.commons.io.IOUtils;

import java.io.*;
import java.util.Date;

public class ObjectOutputStreamTest {
    public static void main(String[] args) {
        OutputStream os = null;
        ObjectOutputStream oos = null;


        try {
            os = new FileOutputStream("/Users/edy/Desktop/file/3.txt");
            oos = new ObjectOutputStream(os);
            String a = "1234";
            Date date = new Date();
            Student student = new Student();


            oos.writeObject(a);
            oos.writeObject(date);
            oos.writeObject(student);
            oos.writeObject(null);
            oos.flush();


        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            IOUtils.closeQuietly(oos);
            IOUtils.closeQuietly(os);
        }

    }
}
